/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Panels;

import constants.GameControllerServerConstants;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import javax.swing.JLayeredPane;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener;

/**
 *
 * @author luc0
 */
public class RightClickDeletePanel extends JPopupMenu{
 JMenuItem deleteItem;

 public RightClickDeletePanel(final MouseEvent evt,final JLayeredPane panel){
      deleteItem = new JMenuItem("Delete");
      deleteItem.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
               GameControllerServerConstants.isOptionInUse = false;
               panel.remove(((Component)evt.getSource()));
               panel.repaint();
            }
        });

         add(deleteItem);

           addPopupMenuListener(new PopupMenuListener() {

            public void popupMenuWillBecomeVisible(PopupMenuEvent e) {

            }

            public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {

            }

            public void popupMenuCanceled(PopupMenuEvent e) {
                GameControllerServerConstants.isOptionInUse = false;
            }
        });
 }
}
